package pe.com.bbva.efcap.servidor.util.formulas;

import org.boris.expr.Expr;
import org.boris.expr.ExprAddition;
import org.boris.expr.ExprArray;
import org.boris.expr.ExprBoolean;
import org.boris.expr.ExprDivision;
import org.boris.expr.ExprDouble;
import org.boris.expr.ExprEqual;
import org.boris.expr.ExprError;
import org.boris.expr.ExprEvaluatable;
import org.boris.expr.ExprException;
import org.boris.expr.ExprExpression;
import org.boris.expr.ExprFunction;
import org.boris.expr.ExprGreaterThan;
import org.boris.expr.ExprGreaterThanOrEqualTo;
import org.boris.expr.ExprInteger;
import org.boris.expr.ExprLessThan;
import org.boris.expr.ExprLessThanOrEqualTo;
import org.boris.expr.ExprMissing;
import org.boris.expr.ExprMultiplication;
import org.boris.expr.ExprNotEqual;
import org.boris.expr.ExprNumber;
import org.boris.expr.ExprPower;
import org.boris.expr.ExprString;
import org.boris.expr.ExprStringConcat;
import org.boris.expr.ExprSubtraction;
import org.boris.expr.ExprType;
import org.boris.expr.ExprTypes;
import org.boris.expr.ExprVariable;
import org.boris.expr.IEvaluationContext;
import org.boris.expr.function.AbstractFunction;
import org.boris.expr.util.Maths;

public class ANO_SEL extends AbstractFunction{
	
    public Expr evaluate(IEvaluationContext context, Expr[] args)
            throws ExprException {
    	
        assertArgCount(args, 2);
        System.out.println(args[0]);
        System.out.println(args[1]);
        System.out.println("Cambiado");
        if(args[0] instanceof ExprAddition){
        	System.out.println("ExprAddition");
        }
        if(args[0] instanceof ExprArray) {
        	System.out.println("ExprArray");
        }
        if(args[0] instanceof ExprBoolean) {
        	System.out.println("ExprBoolean");
        }
        if(args[0] instanceof ExprDivision) {
        	System.out.println("ExprDivision");
        }
        if(args[0] instanceof ExprDouble) {
        	System.out.println("ExprDouble");
        }
        if(args[0] instanceof ExprEqual) {
        	System.out.println("ExprEqual");
        }
        if(args[0] instanceof ExprError) {
        	System.out.println("ExprError");
        }
        if(args[0] instanceof ExprEvaluatable) {
        	System.out.println("ExprEvaluatable");
        }
//        if(args[0] instanceof ExprException) {
//        	System.out.println("ExprException");
//        }
        if(args[0] instanceof ExprExpression) {
        	System.out.println("ExprExpression");
        }
        if(args[0] instanceof ExprFunction) {
        	System.out.println("ExprFunction");
        }
        if(args[0] instanceof ExprGreaterThan) {
        	System.out.println("ExprGreaterThan");
        }
        if(args[0] instanceof ExprGreaterThanOrEqualTo) {
        	System.out.println("ExprGreaterThanOrEqualTo");
        }
        if(args[0] instanceof ExprInteger) {
        	System.out.println("ExprInteger");
        }
        if(args[0] instanceof ExprLessThan) {
        	System.out.println("ExprLessThan");
        }
        if(args[0] instanceof ExprLessThanOrEqualTo) {
        	System.out.println("ExprLessThanOrEqualTo");
        }
        if(args[0] instanceof ExprMissing) {
        	System.out.println("ExprMissing");
        }
        if(args[0] instanceof ExprMultiplication) {
        	System.out.println("ExprMultiplication");
        }
        if(args[0] instanceof ExprNotEqual) {
        	System.out.println("ExprNotEqual");
        }
        if(args[0] instanceof ExprNumber) {
        	System.out.println("ExprNumber");
        }
        if(args[0] instanceof ExprPower) {
        	System.out.println("ExprPower");
        }
        if(args[0] instanceof ExprString) {
        	System.out.println("ExprString");
        }
        if(args[0] instanceof ExprStringConcat) {
        	System.out.println("ExprStringConcat");
        }
        if(args[0] instanceof ExprSubtraction) {
        	System.out.println("ExprSubtraction");
        }
//        if(args[0] instanceof ExprType) {
//        	System.out.println("ExprType");
//        }
//        if(args[0] instanceof ExprTypes) {
//        	System.out.println("ExprTypes");
//        }
        if(args[0] instanceof ExprVariable) {
        	System.out.println("ExprVariable");
        }
        		
        args[0] = new ExprVariable("D12");

        System.out.println(args[0]);
        System.out.println(args[1]);
        double num = asDouble(context, args[0], true);
        int dps = asInteger(context, args[1], true);
        return new ExprDouble(Maths.round(num, dps));
    }
}
